<?php
Core::getInstance()->app_load_class('Admin',false);
Core::getInstance()->sys_load_class('DatabaseTool',false);
class Database extends Admin{
	/*Singleton{{{*/
	public static function getInstance(){
		static $instance=null;
		if($instance===null){ 
			$instance = new self();
		}
		return $instance;
	}
	private function __construct(){}
	private function __clone(){
		trigger_error("Clone is not allowed.", E_USER_ERROR);
	}
	/*}}}*/

	public function importAction(){
		$title='导入数据库';
		if(count($_FILES)>0){
			$content = file_get_contents($_FILES['userfile']['tmp_name']);
			$db_tool = new DatabaseTool();
			$db_tool->import($content);
			echo '<script type="text/javascript">alert("导入成功");</script>';
		}
		include $this->display('database_import.tpl.php');
	}
}
